#pragma once
#include <functional>
#include <list>
#include "../Base/TypeDefine.hpp"
namespace NAMESPACENAME
{
	template<typename _T>
	class Event;
	template<typename _Ret, typename... Args>
	class Event<_Ret(Args...)>
	{
	public:
		using FunctionType = std::function<_Ret(Args...)>;
	protected:
		std::list<FunctionType> delegates;
	public:
		void operator()(Args... a)const
		{
			for (auto& it : delegates)
				it(a...);
		}
		inline Event& operator+=(FunctionType fun)
		{
			delegates.push_back(fun);
			return *this;
		}
		inline Event& operator-=(FunctionType fun)
		{
			if (auto iter(std::find(delegates.begin(), delegates.end(), fun)); iter != delegates.end())
				delegates.erase(iter);
			return *this;
		}
	};
}